package com.chf.carsystem.users.service.imp;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.chf.carsystem.users.dao.IMenuDao;
import com.chf.carsystem.users.dao.IRoleDao;
import com.chf.carsystem.users.dao.IUserDao;
import com.chf.carsystem.users.pojo.Menu;
import com.chf.carsystem.users.pojo.Role;
import com.chf.carsystem.users.pojo.User;
import com.chf.carsystem.users.service.IUserService;

@Service("userService")
public class UserServiceImp implements IUserService{

	@Resource
	private IUserDao iUserDao; 
	
	@Resource
	private IMenuDao iMenuDao; 
	
	@Resource
	private IRoleDao iRoleDao; 
	
	//查询一个user
	@Override
	public User findOneService(Map<String, Object> findOneMap) {
		
		return this.iUserDao.findOne(findOneMap);
	}


	//更新一个user
	@Override
	public int updateOneUserService(User user) {
		
		return this.iUserDao.updateOne(user);
	}

	
	//查询Role下的所有的菜单 调用IMenuDao
	@Override
	public List<Menu> findListMenusByRoleIdService(int roleId) {
		
		return this.iMenuDao.findListMenus(roleId);
		
	}

	//模糊查询role集合
	@Override
	public List<Role> finCountListRolesService(Map<String, Object> findCoundListMap) {
		String name = findCoundListMap.get("name")+"";
		findCoundListMap.put("name",("%"+name+"%"));
		return this.iRoleDao.finCountListRoles(findCoundListMap);
	}

	


	
	
}
